<?php

include("global.php");

$pagetitle=" - Administration - Approvals";
$links=" > Administration > Approvals";

include ("header.php");

include ("admin_header.php");

if($userloggedinarray[15]!=="administrator"){
   echo template('noticenocpaccess');
}else{

 if(!isset($approvedisplay)&&!isset($rejectdisplay)&&!isset($approvereg)&&!isset($rejectreg)){
 	unset($tplcontent);
 	unset($tplcontent2);

  for($n=0;$n<count($usersarray);$n++){
  $userarray=getdata("$configarray[1]/$usersarray[$n]/main.php");
   if($userarray[15]=="approve" || $userarray[15]=="confirm"){
   	unset($tplcontent3);
    $tplcontent3['userid'].=$usersarray[$n];
    $tplcontent3['username'].=$userkeyarray[$usersarray[$n]];
    $tplcontent3['displayname'].=$userarray[0];
    $tplcontent3['email'].=$userarray[2];
    $tplcontent3['type'].=$userarray[15];
    $tplcontent3['approve'].="<a href=\"admin_approve.php?approvereg=$usersarray[$n]\">Approve</a>";
    $tplcontent3['reject'].="<a href=\"admin_approve.php?rejectreg=$usersarray[$n]\">Reject</a>";
    $tplcontent2['regapprovalrows'].=template('adminapproveregrow',$tplcontent3);
   }
  }
 
 if($configarray[39]!=="approve"){
 	$tplcontent['regapproval'].=template('adminapproveregoff',$tplcontent2);
 }else{
 	$tplcontent['regapproval'].=template('adminapproveregon',$tplcontent2);
 }
 
 unset($tplcontent2);

  $displaychangearray=getdata("$configarray[1]/displaychange.php");
  for($n=0;$n<count($displaychangearray);$n++){
   if(trim($displaychangearray[$n])){
   	unset($tplcontent3);
   	$userarray=getdata("$configarray[1]/$n/main.php");
    $tplcontent3['userid'].=$n;
    $tplcontent3['oldname'].=$userarray[0];
    $tplcontent3['newname'].=$displaychangearray[$n];
    $tplcontent3['approve'].="<a href=\"admin_approve.php?approvedisplay=$n\">Approve</a>";
    $tplcontent3['reject'].="<a href=\"admin_approve.php?rejectdisplay=$n\">Reject</a><br>";
    $tplcontent2['displayapprovalrows'].=template('adminapprovedisplayrow',$tplcontent3);
   }
  }
  
 if($configarray[41]!=="approve"){
 	$tplcontent['displayapproval'].=template('adminapprovedisplayoff',$tplcontent2);
 }else{
 	$tplcontent['displayapproval'].=template('adminapprovedisplayon',$tplcontent2);
 }

 echo template('adminapproveview',$tplcontent);
 }

 if(isset($approvedisplay)){

 $displaychangearray=getdata("$configarray[1]/displaychange.php");
 
 writedata("$configarray[1]/$approvedisplay/main.php",$displaychangearray[$approvedisplay],0);
 deletedata("$configarray[1]/displaychange.php",$approvedisplay);

   echo template('noticedisplaychangeapproved');
 }
 
 if(isset($rejectdisplay)){
 deletedata("$configarray[1]/displaychange.php",$rejectdisplay);

   echo template('noticedisplaychangerejected');
 }
 
 if(isset($approvereg)){
 
 writedata("$configarray[1]/$approvereg/main.php","registered",15);

	echo template('noticeregapproved');
 }
 
 if(isset($rejectreg)){
 deleteuser($rejectreg);

   echo template('noticeregrejected');
 }

}

include("admin_footer.php");

include("footer.php");

?>
